package com.designPattern.observer;

/**
 * 使用java自带的订阅、发布
 * @author : liutianlong
 * @date : 2023/5/25
 * @since : 1.0
 */
public class ClientDemo {

    public static void main(String[] args) {
        // 创建订阅端
        BaiDuConsumer baiDuConsumer = new BaiDuConsumer();
        AppleConsumer appleConsumer = new AppleConsumer();

        // 创建发布端
        MessageProducer messageProducer = new MessageProducer("小米");
        // 将订阅端加入到发布端
        messageProducer.addObserver(baiDuConsumer);
        messageProducer.addObserver(appleConsumer);

        messageProducer.createMessage("2023年05月25日发布新手机");


    }
}
